package com.example.demo.mapper;

import com.example.demo.pojo.Admin;
import com.example.demo.pojo.request.AdminPageRequest;
import com.example.demo.pojo.request.BaseRequest;
import com.example.demo.pojo.request.PasswordRequest;
import com.example.demo.pojo.request.UserPageRequest;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.util.List;

@Mapper
@Component
public interface   AdminMapper {


    //查询全部
    List<Admin> list();

    //分页查询
    List<Admin> page(AdminPageRequest request);

    //添加
    @Insert("insert into library.admin (username, phone, password, email,create_time) values " +
            "(#{username}, #{phone}, #{password}, #{email},#{createTime})")
    void save(Admin admin);

    //回写
    @Select("select * from library.admin where id=#{id}")
    Admin getUser(Integer id);

    //编辑
    @Update("update library.admin set username=#{username},phone=#{phone} " +
            ",update_time=#{updateTime},email=#{email} where id=#{id}")
    void getUserByID(Admin admin);

    //删除
    @Delete("delete from library.admin where id=#{id}")
    void delete(Integer id);

    //更新密码
    @Update("update library.admin set password=#{newPass} where id=#{id}  ")
    int changePassword(PasswordRequest passwordRequest);
}
